package com.lecyon.farm.vo.data;

import com.lecyon.farm.common.constant.CommonConstant;
import com.lecyon.farm.common.constant.FarmSysConstant;
import com.lecyon.farm.util.StringHelper;
import lombok.Data;

import java.math.BigDecimal;

/**
 * 按照类型和区域统计作业量
 *
 * @author Yao Zheng
 * @Date 2020/5/25 10:27
 */
@Data
public class StatisticTotalWorkQuantityByAreaAndType {

    private BigDecimal workQuantity;

    private String area;

    private String type;

    private String typeName;

    private String name;

    private StringBuilder stringBuilder = new StringBuilder();

    public void setType(String type) {
        this.type = type;
        if (StringHelper.isNotEmpty(type) && FarmSysConstant.SYS_JOB_TYPE_MAP.containsKey(type)) {
            this.typeName = FarmSysConstant.SYS_JOB_TYPE_MAP.get(type);
        }
    }

    public String getName() {
        stringBuilder.delete(0, stringBuilder.length());
        if (StringHelper.isNotEmpty(area)) {
            stringBuilder.append(area).append(CommonConstant.SYSTEM_SPLIT_STR);
        }
        if (StringHelper.isNotEmpty(typeName)) {
            stringBuilder.append(typeName);
        }
        return stringBuilder.toString();
    }


}
